package org.developer.invocation;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class Demo {

    public static void main(String[] args) {

        RealSubject realSubject = new RealSubject();

        System.getProperties().setProperty("sun.misc.ProxyGenerator.saveGeneratedFiles","true");

        InvocationHandler handler = new DynamicProxy(realSubject);

        Subject subject = (Subject)Proxy.newProxyInstance(handler.getClass().getClassLoader(),realSubject.getClass().getInterfaces(),handler);

        System.out.println(subject.getClass().getName());

        subject.sayHello("mikeLv");
    }
}
